package com.example.rmiserverdemo.component;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
@Configuration
public class RmiServerConfig {
    @Bean
   public Registry registry() throws RemoteException {
        System.setProperty("com.sun.jndi.rmi.object.trustURLCodebase","true");
        Registry registry = LocateRegistry.createRegistry(1099);
        System.out.println("RMI启动，监听：1099 端口");
        return registry;
    }
}
